package com.along.currentlimiting.rateLimiter.service;

import com.google.common.util.concurrent.RateLimiter;
import org.springframework.stereotype.Service;

/*
 * @Author: liujinyi
 * @DateTime: 2025/2/17 17:26
 */
@Service
public class RateLimiterService {

    private final RateLimiter rateLimiter = RateLimiter.create(2.0); // 每秒允许2个请求

    public boolean tryAcquire() {
        return rateLimiter.tryAcquire();
    }
}
